﻿using Ivory;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Paintball.Libaries;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Paintball
{
    public abstract class MapObject : Sprite
    {
        //Fields
        public Texture2D ObjectTexture { get; set; }
        public IEnumerable<Rectangle> DeadZones { get; set; }

        public Color Shade { get; set; }
        public string Name { get; set; }

        public override int LayerIndex
        {
            get { return RenderIndex; }
            set { RenderIndex = (int)MathHelper.Clamp(value, Globals.MinLayerIndex, Globals.MaxLayerIndex); }
        }

        //Construct
        public MapObject(Texture2D texture, Rectangle area, Color shade, params Rectangle[] deadZones)
            : base(area)
        {
            this.ObjectTexture = texture;
            this.Shade = shade;
            this.DeadZones = deadZones;
        }

        //Methods
        protected abstract void Render(SpriteBatch batch, GameTime time);
        protected abstract void Solve(InputControl input, GameTime time);
        protected abstract bool Loading();

        public override void Draw(SpriteBatch batch, GameTime time)
        {

        }
        public override void Update(InputControl input, GameTime time)
        {

        }
        public override bool Load()
        {

            return true;
        }

        protected override void InitalizeBody(FarseerPhysics.Dynamics.Body body)
        {
            body.IsStatic = true;
            base.InitalizeBody(body);
        }

        public void SimpleDraw(SpriteBatch batch)
        {
            batch.Begin();
            batch.Draw(ObjectTexture, BoundingBox, null, Shade, Rotation, Origin, SpriteEffects.None, 0);
            batch.End();
        }
    }
}
